#import <UIKit/UIKit.h>
#import "TopicModel.h"
#import "TopicManager.h"
#import "ShareViewController.h"
#import "ShareManager.h"
#import <MessageUI/MessageUI.h>
#import "TopicActionBar.h"
#import "TopicDetailModel.h"
#import "MWPhotoBrowser.h"
#import "MBProgressHUD.h"

@class TDCUserStateBase;
@class TDCUserStateLogin;
@class TDCUserStateLogout;

@interface TopicDetailController : BaseUIViewController <UIScrollViewDelegate,UITableViewDataSource,UITableViewDelegate,UIWebViewDelegate,ShareViewDelegate,ShareManagerDelegate,TopicActionBarDelegate,IIViewDeckControllerDelegate,BaseUIViewControllerDelegate,NSFetchedResultsControllerDelegate,MBProgressHUDDelegate,MWPhotoBrowserDelegate>
{
    MBProgressHUD               *hudLoading;
    IBOutlet UILabel            *topicTitle;
    IBOutlet UILabel            *topicTime;
    IBOutlet UITableView        *replyTable;
    IBOutlet UIScrollView       *mainView;
    IBOutlet UIView             *insideContent;
    IBOutlet UIView             *topicMainView;
    IBOutlet UIImageView        *topicDetailBg;
    IBOutlet UIView             *replyView;
    
    IBOutlet UILabel *replyCountView;
    IBOutlet UIImageView *replyViewBg;
    
    UITextField                 *replyField;
    TopicModel                  *topic;
    TopicManager                *topicManager;
    
    IBOutlet UIView             *topicActionBarContainer;
    TopicActionBar               *topicActionBar;
    
    ShareViewController         *shareViewController;

    TopicDetailModel *topicDetailModel;
    
    NSMutableArray *viewContent;     //所有的视图
    NSMutableArray *loadingImgView;  //本地loading图
    NSMutableArray *realPicsIndex;   //真实图片索引
    int textTarget;
    int textCount;
    NSMutableArray *browserPhotos;
    BOOL needVerify;
}

@property (atomic, retain) TopicModel                   *topic;
@property (atomic, retain) TopicManager                 *topicManager;
@property (retain, atomic) TDCUserStateLogin            *userStateLogin;
@property (retain, atomic) TDCUserStateLogout           *userStateLogout;
@property (retain, atomic) TDCUserStateBase             *currentUserState;

@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
@property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;


- (void)setUserState:(TDCUserStateBase *)newState;

@end

#pragma mark ---------用户是否登录的状态机-----
@protocol TDCUserStateDelegate<NSObject>
@optional
-(void)TDCUScomment;
-(void)TDCUSfavorite;
@end

@interface TDCUserStateBase : NSObject<TDCUserStateDelegate>
{
    TopicDetailController       *owner;
}
-(id)init:(TopicDetailController *)powner;
@end

@interface TDCUserStateLogin : TDCUserStateBase
@end

@interface TDCUserStateLogout : TDCUserStateBase
@end
